const user = {
	state: {
		isChangePassword: localStorage.getItem('isChangePassword'),
		userInfo: JSON.parse(localStorage.getItem('userInfo') == "" ? null : localStorage.getItem('userInfo')),
		windowSize: '',
		orgInfo: {
			logo:{
				fileUrl:''
			}
		}
	},

	mutations: {
		SET_userInfo: (state, userInfo) => {
			state.userInfo = userInfo
		},
		SET_window_size: (state, windowSize) => {
			state.windowSize = windowSize
		},
		SET_AVATAR: (state, avatar) => {
			state.avatar = avatar
		},
		//设置用户公司信息
		SET_ORGINFO: (state, orgInfo) => {
			state.orgInfo = { ...orgInfo}
		},
		SET_isChangePassword:(state, isChangePassword)=>{
			state.isChangePassword=isChangePassword
		}
	},

	actions: { //异步操作mutation
		// 登录
		set_Login_info({
			commit
		}, userInfo) {
			localStorage.setItem('userInfo', JSON.stringify(userInfo));
			commit('SET_userInfo', userInfo)
		},

		//监听窗口大小
		set_window_size({
			commit
		}, windowSize) {
			console.log('监听窗口',windowSize);
			commit('SET_window_size', windowSize)
		},

		// 登出
		set_LogOut({
			commit
		}, userInfo) {
			localStorage.setItem('userInfo', "");
			// localStorage.clear()
			commit('SET_userInfo', userInfo)
		},
		//用户公司信息
		set_orgInfo({
			commit
		}, orgInfo) {
			// localStorage.clear()
			console.log('vuex存储公司信息', orgInfo)
			commit('SET_ORGINFO', orgInfo)
		},
		set_isChangePassword({commit}, isChangePassword) {
			localStorage.setItem('isChangePassword',isChangePassword)
			console.log('vuex密码策略', isChangePassword)
			commit('SET_isChangePassword', isChangePassword)
		},
	}
}

export default user
